/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufba.lasid.v1.jitclouds.mda.datatypes.report;

import br.ufba.lasid.v1.jitclouds.mda.datatypes.Parametertable;
import br.ufba.lasid.v1.jitclouds.mda.datatypes.enums.ComponentKind;
import br.ufba.lasid.v1.jitclouds.mda.datatypes.enums.ContextKind;
import br.ufba.lasid.v1.jitclouds.mda.datatypes.enums.MDAConstants;
import br.ufba.lasid.v1.jitclouds.mda.datatypes.enums.ProcedureKind;
import br.ufba.lasid.v1.utils.Clock;

/**
 * Represent a report that is implemented as a hash of parameter name and value.
 * A report is named using the context, component and procedure in which it 
 * is related.
 * @author aliriosa
 */
public class Report extends Parametertable{
    public static final String Timestamp = "Timestamp";
    public static final String Name = "Name";       
    
    public Report() {
        set(Timestamp, Clock.getTime());        
    }                
    
    public String constructName(){
        ContextKind    cnt = get(MDAConstants.Context.name());
        ComponentKind  cmp = get(MDAConstants.Component.name());
        ProcedureKind  prc = get(MDAConstants.Procedure.name());
        
        
        String reportName = cnt.name()   + "." + cmp.name() + "." + prc.name();
        
        set(Name, reportName);
        
        return reportName;
        
    }
    
    public String getReportID(){
        
        String reportName = get(Name);
        
        if(reportName == null){
            
            return null;
            
        }//end if report name is null
        
        Long timestamp = get(Timestamp);
        
        return reportName + "." + timestamp;
        
    }
}
